<?php

error_reporting(0);
mb_internal_encoding('utf-8');
mb_regex_encoding('utf-8');

/**
 * Insertion des différentes classes métiers / fonctionnelles
 */
//TOOLS
include_once( "application/tools/Sql.php" );
include_once( "application/tools/Html.php" );
include_once( "application/tools/Authentification.php" );
include_once( "application/tools/Settings.php" );
include_once( "application/tools/Log.php" );

//MODELS
include_once( "application/models/Column.php" );

//VIEWS
include_once "application/views/LoginView.php";

//CONTROLLERS
include_once "application/controllers/LoginController.php";
include_once "application/controllers/GrapheController.php";

/** ouverture de la connexion au serveur de base de données */
Sql::open();

/** ouverture de la session php */
session_start();

/** lancement de l'authentification */
Authentification::doConnect();

/** si l'utilisateur n'est pas authentifié on affiche le formulaire */
if (!Authentification::isAuthenticated()) {

    Html::open();
    $auth = new LoginView();
    $page = LoginController::getPage();
    
    /** page mot de passe perdu */
    if ($page == 0)
        $auth->renderLostPassword();
    else
        $auth->render();

    Html::close();
}
else
    header('Location: main.php?page=0');

/** fermeture de la connexion SQL */
Sql::close();